package com.dswz.utils;

import java.io.Serializable;
import java.util.List;

public class PageBean implements Serializable {
	private static final long serialVersionUID = 1L;
	private int totalRecords;
	private int totalPages;
	private int pageSize;
	private int pageNo;
	private int prevPage;
	private int nextPage;
	private boolean hasPrev;
	private boolean hasNext;
	private String url;
	private List contentList;

	public PageBean() {
	}

	public PageBean(int pageSize, int totalRecords, int pageNo) {
		setPageSize(pageSize);
		setTotalRecords(totalRecords);
		setPageNo(pageNo);
	}

	public int getNextPage() {
		return this.nextPage;
	}

	public void setNextPage(int nextPage) {
		this.nextPage = nextPage;
	}

	public int getPageSize() {
		return this.pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
		if (this.totalRecords == 0) {
			this.totalPages = 0;
		} else {
			this.totalPages = ((this.totalRecords - 1) / pageSize + 1);
		}
	}

	public int getPageNo() {
		return this.pageNo;
	}

	public void setPageNo(int pageNo) {
		if (pageNo < 1)
			pageNo = 1;
		if (pageNo > this.totalPages)
			pageNo = this.totalPages;
		this.pageNo = pageNo;
		if (pageNo > 1) {
			 this.prevPage = (pageNo - 1);
			this.hasPrev = true;
		} else {
			 this.prevPage = 1;
			 this.hasPrev = false;
		}
		 if (pageNo < this.totalPages) {
			 this.nextPage = (pageNo + 1);
			 this.hasNext = true;
		} else {
			 this.nextPage = this.totalPages;
			 this.hasNext = false;
		}
		 this.nextPage = (pageNo + 1);
	}

	public int getPrevPage() {
		 return this.prevPage;
	}

	public void setPrevPage(int prevPage) {
		 this.prevPage = prevPage;
	}

	public int getTotalPages() {
		return this.totalPages;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	public int getTotalRecords() {
		 return this.totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		 this.totalRecords = totalRecords;
		if (totalRecords == 0) {
			 this.totalPages = 0;
		} else {
		 this.totalPages = ((totalRecords - 1) / this.pageSize + 1);
		}
	}

	public boolean isHasNext() {
		 return this.hasNext;
	}

	public void setHasNext(boolean hasNext) {
		 this.hasNext = hasNext;
	}

	public boolean isHasPrev() {
		 return this.hasPrev;
	}

	public void setHasPrev(boolean hasPrev) {
		 this.hasPrev = hasPrev;
	}

	public String getUrl() {
		 return this.url;
	}

	public void setUrl(String url) {
		 this.url = url;
	}

	public List getContentList() {
		 return this.contentList;
	}

	public void setContentList(List contentList) {
		this.contentList = contentList;
	}
}
